/**
 * Witontek.com.
 * Copyright (c) 2012-2017 All Rights Reserved.
 */
package test.annotation;

import java.lang.reflect.Field;

/**
 * 
 * @author Long
 * @version $Id: FruitInfoUtil.java, v 0.1 2017年10月26日 下午3:17:42  xiaolong.ma  Exp $
 */
public class FruitInfoUtil {
    public static void getFruitInfo(Class<?> clazz) {

        String strFruitName = " 水果名称：";

        Field[] fields = clazz.getDeclaredFields();

        for (Field field : fields) {
            if (field.isAnnotationPresent(FruitName.class)) {
                FruitName fruitName = (FruitName) field.getAnnotation(FruitName.class);
                strFruitName = strFruitName + fruitName.value();
                System.out.println(strFruitName);
            }
        }
    }

    public static void main(String[] args) {

        FruitInfoUtil.getFruitInfo(Apple.class);

    }
}
